﻿using System;

using SBPweb.RIA.Shared.Contracts.Extensibility;

namespace SBPweb.RIA.Shared.Contracts.Base
{

    public class ExtendableEventArgs : EventArgs, IExtendable
    {

        #region Fields

        protected ExtendableBase bag = new ExtendableBag();

        #endregion

        #region Constructor logic

        public ExtendableEventArgs()
        {
        }

        protected ExtendableEventArgs(ExtendableEventArgs parent)
        {
            this.bag = parent.bag;
        }

        #endregion

        #region Property accessors

        public T Get<T>(string propertyName)
        {
            return bag.Get<T>(propertyName);
        }

        public void Put<T>(string propertyName, T value)
        {
            bag.Put<T>(propertyName, value);
        }

        public void Remove(int index)
        {
            bag.Remove(index);
        }

        public void Remove(string propertyName)
        {
            bag.Remove(propertyName);
        }

        public void Remove<T>(int index)
        {
            bag.Remove<T>(index);
        }

        public void Remove<T>(string propertyName)
        {
            bag.Remove<T>(propertyName);
        }

        public ExtendableBase UnderlyingBag
        {
            get
            {
                return bag;
            }
        }

        #endregion
        
    }

    public class ExtendableGenericEventArgs<T> : ExtendableEventArgs
    {
        
        #region Constructor logic

        public ExtendableGenericEventArgs()
        {
        }

        protected ExtendableGenericEventArgs(T result)
        {
            this.Result = result;
        }

        protected ExtendableGenericEventArgs(ExtendableEventArgs parent)
            : base(parent)
        {
        }

        #endregion

        #region Properties

        public T Result
        {
            get;
            set;
        }

        #endregion

    }

}